package com.lyncs.ods.modules.txn.controller;

import com.lyncs.ods.common.api.CommonResult;
import com.lyncs.ods.modules.txn.model.DeliverInfo;
import com.lyncs.ods.modules.txn.model.OrderInfo;
import com.lyncs.ods.modules.txn.model.SettlementInfo;
import com.lyncs.ods.modules.txn.service.DeliverInfoService;
import com.lyncs.ods.modules.txn.service.DeliverService;
import com.lyncs.ods.modules.txn.service.OrderInfoService;
import com.lyncs.ods.modules.txn.service.SettlementInfoService;
import com.lyncs.ods.req.SaveDeliverReq;
import com.lyncs.ods.resp.TxnCountResp;
import com.lyncs.ods.utils.TxnCommonUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * <p>
 * ods中公用接口
 * </p>
 *
 * @author alex
 * @since 2022-02-15
 */
@RestController
@RequestMapping("/txn")
@Api(tags = {"ods公用接口"})
public class CommonController {

    @Autowired
    private DeliverInfoService deliverInfoService;
    @Autowired
    private OrderInfoService orderInfoService;
    @Autowired
    private SettlementInfoService settlementInfoService;

    @GetMapping("/count")
    @ApiOperation(value = "单据统计接口")
    public CommonResult<TxnCountResp> saveDeliver() {
        Integer orderCount = TxnCommonUtils.count(orderInfoService.lambdaQuery().setEntityClass(OrderInfo.class));
        Integer deliverCount = TxnCommonUtils.count(deliverInfoService.lambdaQuery().setEntityClass(DeliverInfo.class));
        Integer settlementCount = TxnCommonUtils.count(settlementInfoService.lambdaQuery().setEntityClass(SettlementInfo.class));
        return CommonResult.success(new TxnCountResp(orderCount, deliverCount, settlementCount));
    }
}
